//
//  CreditView.m
//  YTwallet
//
//  Created by ZhangLin on 2019/3/8.
//  Copyright © 2019年 hadrlog. All rights reserved.
//

#import "CreditView.h"
#import <Masonry.h>
@implementation CreditView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupViews];
    }
    return self;
}

-(void)setupViews{

self.topView = [[UIView alloc] init];
[self addSubview:self.topView];
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(0);
    make.right.mas_equalTo(0);
    make.top.mas_equalTo(0);
    make.height.mas_equalTo(100);
}];

self.moneyLab = [[UILabel alloc] init];
self.moneyLab.text = @"收款金额";
self.moneyLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
self.moneyLab.font = [UIFont systemFontOfSize:16];
[self.topView addSubview:self.moneyLab];
[self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(20);
    make.top.mas_equalTo(10);
}];

self.symbolLab = [[UILabel alloc] init];
self.symbolLab.text = @"￥";
self.symbolLab.textColor = [UIColor blackColor];
self.symbolLab.font = [UIFont systemFontOfSize:48];
[self.topView addSubview:self.symbolLab];
[self.symbolLab mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(20);
    make.top.equalTo(self.moneyLab.mas_bottom).offset(10);
    make.width.mas_equalTo(50);
}];

    /*
self.visableLab = [[UILabel alloc] init];
self.visableLab.text = @"0.00";
self.visableLab.textColor = [UIColor blackColor];
self.visableLab.font = [UIFont systemFontOfSize:48];
[self.topView addSubview:self.visableLab];
[self.visableLab mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.symbolLab.mas_right);
    make.top.equalTo(self.moneyLab.mas_bottom).offset(10);
}];
     */
    self.visableTf = [[UITextField alloc] init];
    self.visableTf.font = [UIFont systemFontOfSize:48];
    [self.topView addSubview:self.visableTf];
    [self.visableTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.symbolLab.mas_right);
        make.top.equalTo(self.moneyLab.mas_bottom).offset(10);
        make.right.mas_equalTo(-10);
        make.height.equalTo(self.symbolLab);
    }];

self.topLineView = [[UIView alloc] init];
self.topLineView.backgroundColor = [UIColor colorWithRed:229 / 255.0 green:229 / 255.0 blue:229 / 255.0 alpha:1];
[self.topView addSubview:self.topLineView];
[self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(20);
    make.right.mas_equalTo(-20);
    make.top.equalTo(self.topView.mas_bottom);
    make.height.mas_equalTo(1);
}];


self.midView = [[UIView alloc] init];
[self addSubview:self.midView];
[self.midView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.mas_equalTo(0);
    make.right.mas_equalTo(0);
    make.top.equalTo(self.topLineView);
    make.height.equalTo(self).multipliedBy(0.2);
}];
    
    
    self.collectCardLab = [[UILabel alloc] init];
    self.collectCardLab.text = @"收款卡";
    self.collectCardLab.textColor = [UIColor colorWithRed:153 / 255.0 green:153 / 255.0 blue:153 / 255.0 alpha:1];
    self.collectCardLab.font = [UIFont systemFontOfSize:14];
    [self.midView addSubview:self.collectCardLab];
    [self.collectCardLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.moneyLab);
        make.top.mas_equalTo(20);
    }];
    
    self.collectCardBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    [self.collectCardBtn setImage:[UIImage imageNamed:@"icon_question"] forState:(UIControlStateNormal)];
    [self.midView addSubview:self.collectCardBtn];
    [self.collectCardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.collectCardLab.mas_right);
        make.centerY.equalTo(self.collectCardLab);
    }];
    
    self.collectCardValueLab = [[UILabel alloc] init];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"中国工商银行(尾号0809)"];
    [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, 14)];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:51.0f/255.0f green:51.0f/255.0f blue:51.0f/255.0f alpha:1.0f] range:NSMakeRange(0, 6)];
    
    
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1.0f] range:NSMakeRange(6, 8)];
    self.collectCardValueLab.attributedText = attributedString;
    [self.midView addSubview:self.collectCardValueLab];
    [self.collectCardValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.equalTo(self.collectCardLab);
    }];
    
}
@end
